import { Router } from 'hyper-express';
import requireUser from '../../../middlewares/auth/requireUser';
import cache from '../../../middlewares/cache';
import rowLevelPermission from '../../../middlewares/auth/rowLevelPermission';
//#region AutoCreateCode
import { database_nameEntityController } from '../../../controllers';
const database_nameentityRouter = new Router();
const entityController = new database_nameEntityController();

database_nameentityRouter.post('/add', needRequireUser, entityController.add);
database_nameentityRouter.post('/edit', needRequireUser, rowLevelPermission('database_name/table_name'), entityController.edit);
database_nameentityRouter.post('/del', needRequireUser, rowLevelPermission('database_name/table_name'), entityController.delete);

//For getting entity with permission control
database_nameentityRouter.get('/:id', needRequireUser, needCache, rowLevelPermission('database_name/table_name'), entityController.getSingle);
database_nameentityRouter.get('/:limit/:page', needRequireUser, needCache, rowLevelPermission('database_name/table_name'), entityController.getMany);
database_nameentityRouter.get('/:limit/:page/:skip', needRequireUser, needCache, rowLevelPermission('database_name/table_name'), entityController.getMany);

//#endregion AutoCreateCode
export default database_nameentityRouter;
